/**
 * @(#)ApkConfigController.java 2017年03月1日
 * Copyright(C) 2017 ZHEXIN IT CO.,LTD. All rights reserved.
 */
package org.jsbd.boss.action;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.jsbd.boss.domian.MonitorConfigBean;
import org.jsbd.boss.service.IMonitorConfigService;

import org.jsbd.boss.common.DataGridModel;
import org.jsbd.boss.common.ResponseMapUtils;
import org.jsbd.boss.domian.CabinetConfigBean;
import org.jsbd.boss.service.ICabinetConfigService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;


@Controller
@RequestMapping("/monitorConfig")
public class MonitorConfigController{

	private static final Logger LOGGER=LoggerFactory.getLogger(MonitorConfigController.class);
	
	@Autowired
	private IMonitorConfigService monitorConfigService;

	/**
	 * 列表页面
	 * 
	 * @param model
	 * @return
	 * @throws Exception
	 */
	@RequestMapping(value = "listModel")
	public String showMonitorConfigList(Model model) throws Exception {
		return "/qyChannelMonitorConfig/qyChannelMonitorConfigList";
	}

	@RequestMapping(value = "saveMonitorConfig")
	@ResponseBody
	public Object saveMonitorConfig(MonitorConfigBean monitorConfig){
		monitorConfigService.saveMonitorConfig(monitorConfig);
		return ResponseMapUtils.responseSuccess();
	}

	@RequestMapping(value = "updateMonitorConfig")
	@ResponseBody
	public Object updateMonitorConfig(MonitorConfigBean monitorConfig){
		if (monitorConfig.getId() == null) {
			return ResponseMapUtils.responseFail("参数缺失，请确认参数再提交");
		}
		
		MonitorConfigBean condition=new MonitorConfigBean();
		condition.setId(monitorConfig.getId());
		MonitorConfigBean temp=monitorConfigService.getMonitorConfig(condition);
		if(temp==null){
			return ResponseMapUtils.responseFail("记录未找到,请重试");
		}
		
		monitorConfigService.updateMonitorConfig(monitorConfig);
		return ResponseMapUtils.responseSuccess();
	}

	@RequestMapping(value = "getMonitorConfig")
	@ResponseBody
	public MonitorConfigBean getMonitorConfig(MonitorConfigBean monitorConfig) throws Exception {
		return monitorConfigService.getMonitorConfig(monitorConfig);
	}

	@RequestMapping(value = "getMonitorConfigList")
	@ResponseBody
	public List<MonitorConfigBean> getMonitorConfigList(MonitorConfigBean monitorConfig) throws Exception {
		return monitorConfigService.getMonitorConfigList(monitorConfig);
	}

	@RequestMapping(value = "getMonitorConfigListPage")
	@ResponseBody
	public Map<String, Object> getMonitorConfigListPage(DataGridModel page, MonitorConfigBean monitorConfig) throws Exception {
		return monitorConfigService.getMonitorConfigListPage(page, monitorConfig);
	}
	
	@RequestMapping(value = "deleteMonitorConfig")
	@ResponseBody
	public Map<String, Object> deleteMonitorConfig(MonitorConfigBean monitorConfig) throws Exception {
		monitorConfigService.deleteMonitorConfig(monitorConfig);
		return ResponseMapUtils.responseSuccess();
	}
	

}
